package com.hxy.subject.domain.service.impl;

import com.hxy.subject.domain.convert.SubjectInfoConverter;
import com.hxy.subject.domain.entity.SubjectInfoBO;
import com.hxy.subject.domain.handler.subject.SubjectInfoTypeHandler;
import com.hxy.subject.domain.handler.subject.SubjectTypeFactory;
import com.hxy.subject.domain.service.SubjectInfoDomainService;
import com.hxy.subject.infra.basic.entity.SubjectInfo;
import com.hxy.subject.infra.basic.mapper.SubjectInfoDao;
import com.hxy.subject.infra.basic.service.SubjectInfoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 题目信息表(SubjectInfo)表服务实现类
 *
 * @author makejava
 * @since 2024-09-03 21:25:03
 */
@Service("subjectInfoService")
public class SubjectInfoDomainServiceImpl implements SubjectInfoDomainService {
    @Resource
    private SubjectInfoService subjectInfoService;

    @Resource
    private SubjectTypeFactory subjectTypeFactory;

    @Override
    public void add(SubjectInfoBO subjectInfoBO) {
        SubjectInfo subjectInfo = SubjectInfoConverter.INSTANCE.subjectInfoBoToInfo(subjectInfoBO);
        subjectInfoService.insert(subjectInfo);
        SubjectInfoTypeHandler handler = subjectTypeFactory.getHandler(subjectInfo.getSubjectType());
        handler.add(subjectInfoBO);
    }
}
